/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Interface;

import Negocio.CadastroException;
import Persistencia.DAOException;
import java.awt.Dimension;
import javax.swing.JOptionPane;

/**
 *
 * @author v3550
 */
public class FPrincipal extends javax.swing.JFrame {

    /**
     * Creates new form FPrincipal
     */
    public FPrincipal() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenu1 = new javax.swing.JMenu();
        jMenu3 = new javax.swing.JMenu();
        jMenu4 = new javax.swing.JMenu();
        jMenu6 = new javax.swing.JMenu();
        jMenu7 = new javax.swing.JMenu();
        desktop = new javax.swing.JDesktopPane();
        JMenuBar = new javax.swing.JMenuBar();
        JMenuCadastro = new javax.swing.JMenu();
        JMItemMenuCadastro = new javax.swing.JMenuItem();
        JMenuLeilao = new javax.swing.JMenu();
        jMenuItemConsultarleilao = new javax.swing.JMenuItem();
        JMenuAbandonar = new javax.swing.JMenu();

        jMenu1.setText("jMenu1");

        jMenu3.setText("jMenu3");

        jMenu4.setText("jMenu4");

        jMenu6.setText("jMenu6");

        jMenu7.setText("jMenu7");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        JMenuCadastro.setText("Cadastrar");

        JMItemMenuCadastro.setActionCommand("Casdastro");
        JMItemMenuCadastro.setLabel("Cadastro");
        JMItemMenuCadastro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JMItemMenuCadastroActionPerformed(evt);
            }
        });
        JMenuCadastro.add(JMItemMenuCadastro);

        JMenuBar.add(JMenuCadastro);

        JMenuLeilao.setText("Leilão");

        jMenuItemConsultarleilao.setText("Consultar");
        jMenuItemConsultarleilao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JmenuItemConsLeilao(evt);
            }
        });
        JMenuLeilao.add(jMenuItemConsultarleilao);

        JMenuBar.add(JMenuLeilao);

        JMenuAbandonar.setText("Abandonar");
        JMenuAbandonar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                JMenuAbandonarMouseClicked(evt);
            }
        });
        JMenuBar.add(JMenuAbandonar);

        setJMenuBar(JMenuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(desktop, javax.swing.GroupLayout.PREFERRED_SIZE, 813, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktop, javax.swing.GroupLayout.DEFAULT_SIZE, 510, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void JMenuAbandonarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_JMenuAbandonarMouseClicked
        // TODO add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_JMenuAbandonarMouseClicked

    private void JMItemMenuCadastroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JMItemMenuCadastroActionPerformed
        // TODO add your handling code here:
        try {
                   
                    FConfiguracao f = new FConfiguracao();
                    Dimension deskSize = desktop.getSize();  
                    f.setBounds(0, 0, deskSize.width, deskSize.height);
                    desktop.add(f);
                    f.setVisible(true); 
                } catch (CadastroException ex) {
                    System.out.println("Erro fatal: " + ex.getMessage());
                    System.out.println(ex.toString());
                    System.exit(0);
                } catch(DAOException e){
                     System.out.println(e.toString());
                }catch(Exception e){
                    System.out.println(e.toString());
                }
    }//GEN-LAST:event_JMItemMenuCadastroActionPerformed

    private void JmenuItemConsLeilao(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JmenuItemConsLeilao
        // TODO add your handling code here:
           try {
                   
                    FLeilao f = new FLeilao();
                    Dimension deskSize = desktop.getSize();  
                    f.setBounds(0, 0, deskSize.width, deskSize.height);
                    desktop.add(f);
                    f.setVisible(true); 
                } catch (CadastroException ex) {
                    System.out.println("Erro fatal: " + ex.getMessage());
                    System.out.println(ex.toString());
                    System.exit(0);
                } catch(DAOException e){
                     System.out.println(e.toString());
                } catch(Exception  e )
                {
                    System.out.println(e.toString());
                }
    }//GEN-LAST:event_JmenuItemConsLeilao

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                FPrincipal f = new FPrincipal();
                f.setLocationRelativeTo(null);
                f.setVisible(true);
                
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem JMItemMenuCadastro;
    private javax.swing.JMenu JMenuAbandonar;
    private javax.swing.JMenuBar JMenuBar;
    private javax.swing.JMenu JMenuCadastro;
    private javax.swing.JMenu JMenuLeilao;
    private javax.swing.JDesktopPane desktop;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu6;
    private javax.swing.JMenu jMenu7;
    private javax.swing.JMenuItem jMenuItemConsultarleilao;
    // End of variables declaration//GEN-END:variables
}
